const express = require('express');
const cors = require('cors');
const userRoutes = require('./routes/users');
const containerRoutes = require('./routes/containers');

const app = express();
const PORT = process.env.PORT || 3001;

// 中间件
app.use(cors());
app.use(express.json());
app.use(express.urlencoded({ extended: true }));

// 路由
app.use('/api/users', userRoutes);
app.use('/api/containers', containerRoutes);

// 根路由
app.get('/', (req, res) => {
  res.json({ message: '港口管理系统API服务器正在运行' });
});

// 启动服务器
app.listen(PORT, () => {
  console.log(`服务器正在端口 ${PORT} 上运行`);
});